package com.study.a20youhuaMAX;

import java.util.ArrayList;
import java.util.Collections;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class Test {
    public static void main(String[] args) throws ExecutionException, InterruptedException {

        ArrayList<Integer> list=new ArrayList<>();
        Collections.addAll(list,10,15,52,200,300);

        //创建多线程运行参数对象
        MyCallable mt1= new MyCallable(list);

        //创建多线程运行结果的管理者对象
        FutureTask<Integer> ft=new FutureTask<>(mt1);
        FutureTask<Integer> f2=new FutureTask<>(mt1);


        Thread t1=new Thread(ft);
        Thread t2=new Thread(f2);

        t1.setName("抽奖箱1");
        t2.setName("抽奖箱2");
        t1.start();
        t2.start();

        Integer max1=ft.get();
        Integer max2=f2.get();
        System.out.println(max1);
        System.out.println(max2);
    }
}
